home *** CD-ROM | disk | FTP | other *** search
- {$APPTYPE CONSOLE}
- {$I-}
- uses
- SysUtils;
-
- const
- website = 'http://www.drbob42.com';
-
- const
- IdentSet = ['A'..'Z','a'..'z','0'..'9','-','+'];
- StartSet = ['A'..'Z','a'..'z'];
-
- var
- f: Text;
- MaxFileName, MaxKeyword, Str: ShortString;
- MaxLen: Byte absolute MaxKeyword;
- Len: Byte absolute Str;
- WebPages: Word = 0;
- Size: LongInt = 0;
-
- procedure ScanFiles;
- var
- SRec: TSearchRec;
- NotInTag: Boolean;
- begin
- if FindFirst('*.*', faDirectory, SRec) = 0 then
- repeat
- if (SRec.Attr AND faDirectory) = faDirectory then
- begin
- if (SRec.Name[1] <> '.') then { skip '.' and '..' }
- if Pos('_vti',SRec.Name) = 0 then { _vti_cnf etc. }
- begin
- ChDir(SRec.Name);
- if IOResult = 0 then
- begin
- writeln('<LI><I>',SRec.Name,'</I>');
- writeln('<UL>');
- ScanFiles; { recursive!! }
- writeln('</UL>');
- ChDir('..')
- end
- else
- writeln('<LI><I>',SRec.Name,'</I> - locked')
- end
- end
- else { file }
- if (Pos('.HTM',UpperCase(SRec.Name)) > 0) or
- (Pos('.ASP',UpperCase(SRec.Name)) > 0) then
- begin
- writeln('<LI><B>',SRec.Name, '</B> (',SRec.Size,' bytes)');
- Size := Size + SRec.Size;
- assign(f,SRec.Name);
- reset(f);
- if IOResult = 0 then
- begin
- Inc(WebPages);
- NotInTag := True;
- while not eof(f) do
- begin
- Len := 0;
- while not eoln(f) do
- begin
- Inc(Len);
- read(f,Str[Len]);
- if not (Str[Len] in IdentSet) then
- begin
- Dec(Len);
- if (Len > MaxLen) and NotInTag then
- begin
- MaxKeyword := Str;
- MaxFileName := SRec.Name
- end;
- if Str[Len+1] = '>' then NotInTag := True
- else
- if Str[Len+1] = '<' then NotInTag := False;
- Len := 0
- end
- else
- if (Len = 1) then { start with letter ?? }
- if not (Str[1] in StartSet) then Len := 0
- end;
- if (Len > MaxLen) and NotInTag then
- begin
- MaxKeyword := Str;
- MaxFileName := SRec.Name
- end;
- readln(f)
- end;
- close(f)
- end
- end
- until FindNext(SRec) <> 0;
- FindClose(SRec)
- end {ScanFiles};
-
- begin
- ChDir('..'); { get out of cgi-bin }
- if IOResult <> 0 then { skip };
- writeln('content-type: text/html');
- writeln;
- writeln('<HTML>');
- writeln('<BODY BACKGROUND="/gif/back.gif">');
- writeln('<H2>IndexBob</H2>');
- writeln('Scanning website ',website);
- writeln('<P>');
- writeln('<UL>');
- ScanFiles;
- writeln('</UL>');
- writeln('<HR>');
- writeln('Longest Keyword: ',MaxLen,' =[',MaxKeyword,'] in ',MaxFileName);
- writeln('<BR>Number of Webpages: ',WebPages,' (',Size div 1024,' Kbytes)');
- writeln('<HR>');
- writeln('</BODY>');
- writeln('</HTML>')
- end.
-